Skip to content

[FIX] purchase_request: handle move_dest_ids as False in Odoo 18#3019

Open
fsmw wants to merge 2 commits intoOCA:18.0from
fsmw:18.0-fix-purchase-request-move-dest-ids
Open

[FIX] purchase_request: handle move_dest_ids as False in Odoo 18#3019
fsmw wants to merge 2 commits intoOCA:18.0from
fsmw:18.0-fix-purchase-request-move-dest-ids

Conversation

@fsmw
Copy link
Copy Markdown
Contributor

@fsmw fsmw commented Apr 19, 2026

Description

In Odoo 18, procurement.values.get('move_dest_ids') can return False (boolean) instead of an empty list when no destination moves exist.

The previous code used get('move_dest_ids', []) which only uses the default when the key doesn't exist, not when it's explicitly False.

This causes: TypeError: 'bool' object is not iterable

Fix

Changed line 25 in purchase_request/models/stock_rule.py from:

(4, x.id) for x in procurement.values.get("move_dest_ids", [])

to:

(4, x.id) for x in (procurement.values.get("move_dest_ids") or [])

This ensures we always have an iterable list.

Related Issue

Closes #2927


I am a contributor from the SMWLAB community and this is my first OCA PR. Please review!

In Odoo 18, procurement.values.get('move_dest_ids') can return False
(boolean) instead of an empty list when no destination moves exist.
The previous code used get('move_dest_ids', []) which only uses the
default when the key doesn't exist, not when it's explicitly False.

This causes: TypeError: 'bool' object is not iterable

Fix: use 'or []' to ensure we always have an iterable list.

Closes: OCA#2927
Copilot AI review requested due to automatic review settings April 19, 2026 01:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an Odoo 18 compatibility issue in purchase_request where procurement.values.get("move_dest_ids") may be False (not iterable), causing a TypeError during purchase request line preparation.

Changes:

  • Make _prepare_purchase_request_line robust to move_dest_ids=False by falling back to an empty iterable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread purchase_request/models/stock_rule.py
Add test for issue OCA#2927 to ensure procurement works when move_dest_ids
is False/None, which can happen in Odoo 18. This test prevents
regression of TypeError: 'bool' object is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

purchase_request: "move_dest_ids": TypeError: 'bool' object is not iterable

3 participants